import fetch from "../../utils/request";
import newAxios from '../../utils/authToken';
export function getAllMetaDataTypes() {
  let params = {
    pageNum: 0,
    pageSize: 0
  }
  return newAxios()({ url: "/api/metaType/findAll", method: "get", params });
}
export function getAllCount(metaIds) {
  let params = {
    metaIds: metaIds.toString(),
  };
  return newAxios()({ url: "/api/metaType/findAllCount", method: "get", params });
}
export function deleRecord( metaId) {
  let params = {
    metaId: metaId,
  };
  return newAxios()({ url: "/api/metaType/delete", method: "get", params });
}
export function addNew(name, description, number) {
  let params = {
    name: name,
    description: description,
    number: number,
  };
  return newAxios()({ url: "/api/metaType/add", method: "post", params });
}
export function viewInfo( metaId) {
  let params = {
    metaId: metaId,
  };
  return newAxios()({ url: "/api/metaInfo/findAllNoPage", method: "post", params });
}
export function editCate(name, description, id) {
  let params = {
    description: description,
    metaId: id,
    name: name,
  };
  return newAxios()({
    url: "/api/metaType/changeMetadataType",
    method: "post",
    params,
  });
}
export function searchIn( userId, number) {
  let params = {
    name: userId,
    number: number,
    pageNum: 0,
    pageSize: 0,
  };
  return newAxios()({ url: "/api/metaType/findByFuzzyName", method: "get", params });
}
export function onlySearchType( type, metaid) {
  let params = {
    type: type,
    cnname: "",
    name: "",
    metaId: metaid,
    pageNum: 0,
    pageSize: 0,
  };
  return newAxios()({
    url: "/api/metaInfo/findByFuzzyName",
    method: "post",
    params,
  });
}
export function unitSearch(type, cnname, enname, metaid) {
  let params = {
    type: type,
    cnname: cnname === undefined ? "" : cnname,
    name: enname === undefined ? "" : enname,
    metaId: metaid,
    pageNum: 0,
    pageSize: 0,
  };
  return newAxios()({
    url: "/api/metaInfo/findByFuzzyName",
    method: "post",
    params,
  });
}
export function getListInfo(metaId) {
  let params = {
    metaId: metaId,
  };
  return newAxios()({ url: "/api/metaInfo/findAllNoPage", method: "post", params });
}
export function metaAdd( addValues) {
  return newAxios()({ url: '/api/metaInfo/add', method: 'post', data: addValues });
}
export function deleListRecord( dataId) {
  let params = {
    dataId: dataId,
  };
  return newAxios()({ url: "/api/metaInfo/delete", method: "get", params });
}
export function editList( editValues) {
  return newAxios()({ url: '/api/metaInfo/changeMetaDataInfo', method: 'post', data: editValues })
}
export function downloadModal() {
  /* return axios.get("/apc/metaInfo/download", { responseType: "blob" }); */
  return newAxios()({ url: '/api/metaInfo/download', method: 'get', responseType: 'blob' })
}
export function exportMo( sendMetaId) {
  /*   return axios.get("/apc/metaInfo/export?metaId=" + sendMetaId, {
      responseType: "blob",
    }); */
  let params = {
    metaId: sendMetaId
  }
  return newAxios()({ url: "/api/metaInfo/export", method: 'get', params, responseType: 'blob' })
}
export function imp(update) {
  /* return axios.post("/apc/metaInfo/import", update); */
  return newAxios()({ url: '/api/metaInfo/import', method: 'post', data: update })
}
